/*
 * Capstone.h
 *
 * Created: 1/18/2013 8:49:04 PM
 *  Author: Alexander
 */ 


#ifndef CAPSTONE_H_
#define CAPSTONE_H_

// AVR


#include <avr/io.h>
#include "U0_UART.h"
#include "stdio.h"
#include <stdint.h>
#include <util/delay.h>

// AVRx
#include "avrx-io.h"
#include "avrx-signal.h"
#include "avrx.h"
#include "serialio.h"       // From AvrX...
#include "avrx_hardware_custom.h"
#include "AvrXYieldHack.h"

// SWP
#include "Gyro.h"
#include "Vector_Class.h"
#include "Motor_Driver.h"
//#include "Pressure_Sensor.h"
//#include "Motor_Driver.h"


/************************************************************************/
/* DEFINITIONS															*/
/************************************************************************/

/*********************PORTB*********************/
#define P_Gyro				PB0	//Gyro SS (Active Low)
#define P_SCK				PB1	//SPI SCLK
#define P_MOSI				PB2	//SPI MOSI
#define P_MISO				PB3	//SPI MISO
#define P_Something_PWM		PB4	//0C0A
#define P_Something2_PWM	PB5	//0C1A
#define P_Something3_PWM	PB6	//0C1B
/*DO NOT USE, AvrX uses Timer 2
#define P_Something4_PWM	PB7	//0C2A
*/

/*********************PORTD*********************/

#define P_Pressure			PD0	//Pressure Sensor SS (Active Low)
#define P_Pump				PD1	// Water Pump
#define P_Solenoid			PD2	// Solenoid


extern FILE uart_stream;

void Gyro_Init(void);
int main(void);
void Calculate_Angle(AxesVector_t* zero_rate_vector, AxesVector_t* vector, AxesVector_t* prev_vector);
void Vector_Init(AxesVector_t* vector);
void Timer_Init();

Mutex turnServos;

 AVRX_GCC_TASKDEF(Gyro, 100, 2);
 AVRX_GCC_TASKDEF(GyroAverage, 100, 1);
 AVRX_GCC_TASKDEF(Pump, 0, 2);
// AVRX_GCC_TASK(Pump, 0, 2);
// AVRX_GCC_TASK(Servos, 0,3);
// AVRX_GCC_TASK(Pressure_Sensor, 0, 3);





/*********************GLOBAL DEFS*********************/

	#define	GyroDelay	5	//ms
	#define MaxPumpTime 20 //s
	
#endif /* CAPSTONE_H_ */